<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %><%--
  Created by IntelliJ IDEA.
  User: j
  Date: 2020/10/16
  Time: 15:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<jsp:useBean id="user" class="com.media.bean.UserBean" scope="application"></jsp:useBean>
<jsp:setProperty name="user" property="*"></jsp:setProperty>
<%
    //UserBean user1=new UserBean();
    //user.setUsername(request.getParameter("username"));
    //out.print(user.getUsername());

    //加载驱动程序
    Class.forName("com.mysql.jdbc.Driver");

    //建立数据库连接
    String url = "jdbc:mysql://127.0.0.1:3306/book?user=root&password=root";

    Connection connection = DriverManager.getConnection(url);//获得链接对象

    //String sql = "INSERT INTO user (username,password,gender,age) VALUES('"+user.getUsername()+"','"+user.getPassword()+"',1,23)";

    Statement stmt = connection.createStatement();

    String sql = "delete from user where id =1";

    int count = stmt.executeUpdate(sql);

    if(count == 0){
        out.print("更新失败");
    }else {
        out.print("更新成功");
    }

%>
<jsp:getProperty name="user" property="username"/>
</body>
</html>
